package com.hzdesk.media.koreabatchmatvector.logic.view;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.hzdesk.media.koreabatchmatvector.R;
import com.hzdesk.media.koreabatchmatvector.logic.contract.FileSelectContract;
import com.hzdesk.media.koreabatchmatvector.logic.persenter.FileSelectPersenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import me.zhouzhuo.zzhorizontalprogressbar.ZzHorizontalProgressBar;

/**
 * Created by Administrator on 2018/7/9.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 * <p>
 * TODO: 2018/7/10                                                                               选择文件
 */

public class FileSelectActivity extends BaseActivity implements FileSelectContract.IFileSelectView {

    @BindView(R.id.activity_file_select_iv_back)
    ImageView activityFileSelectIvBack;
    @BindView(R.id.activity_file_select_horizontalprogressbar)
    ZzHorizontalProgressBar activityFileSelectHorizontalprogressbar;
    @BindView(R.id.activity_file_select_path)
    TextView activityFileSelectPath;
    @BindView(R.id.activity_file_select_listview)
    ListView activityFileSelectListview;
    @BindView(R.id.activity_file_select_ll_bg)
    LinearLayout activityFileSelectLlBg;

    private FileSelectPersenter mFileSelectPersenter = new FileSelectPersenter(this);

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_file_select);
        ButterKnife.bind(this);
        mFileSelectPersenter.initDate(activityFileSelectListview, this);
    }

    @OnClick({R.id.activity_file_select_iv_back, R.id.activity_file_select_path})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.activity_file_select_iv_back:
                mFileSelectPersenter.onckilcedBack();
                break;
            case R.id.activity_file_select_path:
                mFileSelectPersenter.onClickedSelectPath();
                break;
        }
    }

    @Override
    protected void onStart() {
        super.onStart();
        final SharedPreferences mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        int selector = mSharedPreferences.getInt("item_skin", 0); //todo 名称
        activityFileSelectLlBg.setBackgroundResource(updateBg[selector]);
    }

    @Override
    public void settotalProgress(int progress) {
        activityFileSelectHorizontalprogressbar.setProgress(progress);
    }

    @Override
    public void toFinshPager() {
        finish();
    }

    @Override
    public void showFileSelectPath(String msg) {
        activityFileSelectPath.setText(msg);
    }

    @Override
    public void setEnabled(Boolean flag) {
        activityFileSelectPath.setEnabled(flag);
    }

}
